package com.designPattern.singleton;

/**
 * 双重加锁，解决多线程，且避免性能问题
 */
public class Singleton4 {
	
	private volatile static Singleton4 instance;
	
	private Singleton4(){
		super();
	}

	/**
	 * 双重加锁提高性能
	 * @return
	 */
	public static Singleton4 getInstance() {
		if(instance == null){
			synchronized (Singleton4.class) {
				if(instance == null){
					instance = new Singleton4();
				}
			}
		}
		return instance;
	}
}//class
